package bat.ke.qq.com.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * 源码学院-Fox
 * 只为培养BAT程序员而生
 * http://bat.ke.qq.com
 * 往期视频加群:516212256 暗号:6
 */
@Controller
public class UserController {


    @RequestMapping("/hello.do")
    @ResponseBody
    public String sayHello( ){

        return "fox";
    }

    @RequestMapping(value = "/hello2.do")
    @ResponseBody
    public Map<String,String> sayHello2(){
        //json
        Map<String,String> map = new HashMap<>();
        map.put("name","fox");
        return map;
    }

    @RequestMapping("/user.do")
    public ModelAndView user(){
        ModelAndView mv = new ModelAndView("user");
        mv.addObject("name","fox");
        // int i=1/0;
        return mv;
    }
}
